package com.jinlejia.bbs.help.binding;

import android.widget.ImageView;

import androidx.databinding.BindingAdapter;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.jinlejia.bbs.R;

/**
 * @author 王进 on 2019/3/5.
 */

public final class DataBindingAdapter {
    @BindingAdapter({"glide"})
    public static void loadImage(ImageView view, String imageUrl){
        Glide.with(view.getContext())
                .load(imageUrl)
                .dontAnimate()
                .placeholder(R.mipmap.bbs_user_no_avatar)
                .fallback(R.mipmap.bbs_user_no_avatar)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .into(view);
    }
}
